package br.com.consignum.negocio;

import java.io.Serializable;

import android.content.Context;
import android.widget.Toast;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public abstract class BaseBO<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private Gson gson = null;
    private Class<T> classe;

    public BaseBO(final Class<T> classe) {
	this.classe = classe;
	gson = new GsonBuilder().create();
    }

    public T converterJsonParaObjeto(final String json) {
	return gson.fromJson(json, classe);
    }

    public String converterObjetoParaJson(final T classe) {
	return gson.toJson(classe);
    }

    public void addMsg(final Context activity, final String msg) {
	Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show();
    }
}
